package com.heima.mvplibrary.dailog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Typeface;
import android.graphics.drawable.AnimationDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.heima.mvplibrary.R;
import com.wang.avi.AVLoadingIndicatorView;


/**
 *  @author Jins
 *  @date created at：2021/9/3
 *  @Description: 加载动画
 */
public class LoadingDailog extends Dialog {

    public LoadingDailog(Context context) {
        super(context);
    }

    public LoadingDailog(Context context, int themeResId) {
        super(context, themeResId);
    }

    public static class Builder {

        private Context context;
        private AVLoadingIndicatorView avi;
        private TextView masg;

        public Builder(Context context) {
            this.context = context;
        }



        public LoadingDailog create() {
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final LoadingDailog dialog = new LoadingDailog(context, R.style.dialog);
            View layout = inflater.inflate(R.layout.dialog_loading, null);
            dialog.addContentView(layout, new ViewGroup.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
            masg = (TextView) layout.findViewById(R.id.masg);
            masg.setTypeface(Typeface.createFromAsset(context.getAssets(),"fonts/aaaaaa.TTF"));


            avi = (AVLoadingIndicatorView) layout.findViewById(R.id.avi);
            startAnim();
            return dialog;

        }

        void startAnim(){
            avi.show();
//            avi.smoothToShow();
        }

        void stopAnim(){
            avi.hide();
            // or avi.smoothToHide();
        }

        private void initView() {

        }
    }
}
